window.onload = function () {
  
  // 存数据
  const arr=[

    {
    
    "任务编号": "XAHH1234567",
    
    "发货起点": "北京市昌平区回龙观街道西三旗桥东金燕龙写字楼 8877 号",
    
    "收货地址": "河南省郑州市路北区北清路 99 号",
    
    "提货时间": "2022.05.04 13:00"
    
    },
    
    {
    
    "任务编号": "XAHH2345678",
    
    "发货起点": "北京市朝阳区望京南湖南路 18 号院 1 号楼",
    
    "收货地址": "河南省郑州市二七区民主路 23 号",
    
    "提货时间": "2022.05.05 14:00"
    
    },
    
    {
    
    "任务编号": "XAHH3456789",
    
    "发货起点": "北京市海淀区中关村东路 1 号院",
    
    "收货地址": "河南省郑州市中原区建设西路 123 号",
    
    "提货时间": "2022.05.06 15:00"
    
    },
    
  ]
  render()
  function render() {
    const box=document.querySelector('.body')
   
    const Newarr = arr.map((item,index)=> {
      return `
      <div class="tasknum${index}">
      <div class="top")'>任务编号：${item["任务编号"]}</div>
      <span class="radius1">起</span>
      <div class="verticalline"></div>
      <span class="radius2">止</span>
      <p class="article1">${item["发货起点"]}</p>
      <p class="article2">${item['收货地址']}</p>
      <div class="line"></div>
      <div class="gettime">
        提货时间 <span class="time">${item['提货时间']}</span>
      </div>
    </div>`
    })

    box.innerHTML=Newarr.join('')
  }
  localStorage.setItem('datas', JSON.stringify(arr))
   // 点击任务编号跳转
  const taskmove=document.querySelector('.body')
  taskmove.addEventListener('touchstart', (e) => {
    if (e.target.tagName === 'DIV') {
      location.href='./任务-待提货-详情.html'
    }
  })
  // 已完成、待提货跳转
  const nottakegoods = document.querySelector('.tophead .nottakegoods')
  nottakegoods.addEventListener('touchstart', () => {
    location.href='待提货列表.html'
  })
  // 重置筛选互换
  const timestart = document.querySelector('.timebox .timestart')
  const timeend = document.querySelector('.timebox .timeend')
  const select = document.querySelector('.timebox .select')
  const box=document.querySelector('.body')
  const hidebox = document.querySelector('.hidebox')
  const allshow=document.querySelector('.allshow')
  // let flag=0
  // timestart.addEventListener('touchstart', () => {
  //   flag=1
  // })
  timeend.addEventListener('touchstart', () => {
    if ( timestart.value !== '') {
      select.style.backgroundColor = '#EF4F3F'
      select.disabled=false
    }
    // if (flag===1 ) {
    //   select.style.backgroundColor = '#EF4F3F'
    //   select.disabled=false
    //   flag=2
    // }
  })
  // if (timeend.value !== '' && timestart.value !== '') {
  //   select.style.backgroundColor = '#EF4F3F'
  // }
  let flag=false
  select.addEventListener('touchstart', (e) => {
    if (timeend.value === '' || timestart.value === '') return
    if (flag===true) {
      select.innerText = '筛选'
      select.style.backgroundColor = '#FADCD9'
      select.disabled = false
      box.style.display = 'block'
      hidebox.style.opacity = 0
      allshow.style.display = 'block'
      flag=false
      return
    }
    if (timeend.value !== '2021-05-21' && timestart.value !== '2020-05-21') {
      alert('未找到对应的信息')
      return
    } else{
      select.innerText = '重置'
      select.style.backgroundColor='#EF4F3F'
      box.style.display = 'none'
      hidebox.style.opacity = 1
      allshow.style.display = 'none'
      flag=true
    }
    // if (timeend.value === '2021-05-21' && timestart.value === '2020-05-21') {
    //   select.innerText = '筛选'
    //     select.style.backgroundColor = '#FADCD9'
    // }
    // if (flag===true) {
    //   select.innerText = '筛选'
    //   select.style.backgroundColor = '#FADCD9'
    //   select.disabled = false
    //   box.style.display = 'block'
    //   hidebox.style.opacity = 0
    //   allshow.style.display='block'
    // }
    // else {
    //   select.innerText = '筛选'
    //   select.style.backgroundColor = '#FADCD9'
    //   select.disabled = false
    //   box.style.display = 'block'
    //   hidebox.style.opacity=0
    // }
  })
//  搜索框点击事件
  const tasknum=document.querySelector('.tasknum')
  const tasknum2=document.querySelector('.tasknum2')
  const tasknum3 = document.querySelector('.tasknum3')
  const searchbox= document.querySelector('.search .searchbox')
  const search=document.querySelector('.search input')
  searchbox.addEventListener('touchstart', () => {
    if (search.value === 'XAHH1234567') {
      tasknum2.style.display='none'
      tasknum3.style.display='none'
    }
    if (search.value === '') {
      tasknum2.style.display='block'
      tasknum3.style.display='block'
    }
  })
  

   // 页面跳转
   const b = document.querySelector('.common_button .b')
   b.addEventListener('touchstart', function () {
     location.href = 'news&&mission.html'
   })
   const c = document.querySelector('.common_button .c')
   c.addEventListener('touchstart', function () {
     location.href = '我的主页.html'
   })
 
}